package cn.lili.modules.goods.client;

import cn.lili.modules.constant.ServiceConstant;
import cn.lili.modules.goods.entity.dos.Category;
import cn.lili.modules.goods.entity.vos.CategoryBrandVO;
import cn.lili.modules.goods.entity.vos.CategoryVO;
import cn.lili.modules.goods.fallback.CategoryFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 商品服务分类client
 *
 * @author Chopper
 * @version v1.0 2021-11-08 09:52
 */
@FeignClient(path = "${server.servlet.context-path}", name = ServiceConstant.GOODS_SERVICE, contextId = "category", fallback = CategoryFallback.class)
public interface CategoryClient {

    /**
     * 获取一级分类列表 用于商家入驻选择
     *
     * @return 分类列表
     */
    @GetMapping("/feign/goods/category/first")
    List<Category> firstCategory();

    /**
     * 获取一级分类列表 用于商家入驻选择
     *
     * @return 分类列表
     */
    @GetMapping("/feign/goods/category/query")
    Category getById(@RequestParam String id);

    @PostMapping("/feign/goods/category/listByIdsOrderByLevel")
    List<Category> listByIdsOrderByLevel(@RequestBody List<String> asList);

    /**
     * 批量获取分类
     *
     * @return 分类列表
     */
    @PostMapping("/feign/goods/category/query/list")
    List<Category> listByIds(@RequestBody List<String> asList);

    /**
     * 批量获取分类
     *
     * @return 分类列表
     */
    @PostMapping("/feign/goods/category/query/list/name")
    Object getCategoryNameByIds(@RequestBody List<String> asList);

    /**
     * 根据分类id查询品牌信息
     *
     * @param categoryId 分类id
     * @return 分类品牌关联信息列表
     */
    @PostMapping("/feign/goods/category/brand/getCategoryBrandList")
    List<CategoryBrandVO> getCategoryBrandList(@RequestParam String categoryId);

    /**
     * 查询所有的分类，父子关系
     *
     * @param parentId 分类父ID
     * @return 所有的分类，父子关系
     */
    @PostMapping("/feign/goods/category/listAllChildren")
    List<CategoryVO> listAllChildren(@RequestParam String parentId);
}
